import java.util.Scanner;
    public class zhishu {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入想要查找的范围：");
            int N = scanner.nextInt();
            int m = 0;
            int j;
            int i;
            for (i= 2; i <= N; i++) {
                int k = (int) Math.sqrt(i);    //计算至需要求的数的开方即可
                for(j=2;j<=k;j++)
                if (i % j == 0)
                    break;
                if (j > k) {
                    System.out.printf("%4d",i);
                    m++;
                    if (m == 5) {
                        System.out.println();
                        m = 0;
                    }
                }
            }
        }
}

